home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 51
/
Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso
/
-in_the_mag-
/
pdselect
/
awnp
/
awnp-docs
/
demos
/
host.rx
< prev
next >
Wrap
Text File
|
2000-02-16
|
2KB
|
86 lines
/*
Arexx Host demo for AWNPipe
William H.M Parker 03 Aug 1999
At first glance writing an arexx host in Arexx looks redundant, but is
actualy a great way to have different scripts comunicate with each other.
AWNPipe can be used from 'C' or other languages to easily add an
Arexx host to your aplications as well.
*/
trace('E')
call buildgui
/*loop untill the user closes window*/
do while ~eof(ca)
/* start the pipe events */
call topipe("con")
/*parse an event from the pipe*/
parse value readln(ca) with in in1 in2 in3 in4 .
if in='arexx' then call rxevent()
end
/*user must have closed window because eof has been received*/
exit
buildgui:
call open(ca,"awnpipe://xc")
/* modify is turned on se we can send results back from arexx commands*/
call topipe(' " Arexx Host" defg m v ')
/* this line is the whole host definition ! */
call topipe('arexx gt "TESTHOST|author|date|add|quit"')
/* some info for the user*/
call topipe('label gt "*n Host name TESTHOST *n *n"')
call topipe('label gt " Available commands"')
call topipe('label gt " Author"')
call topipe('label gt " Date"')
call topipe('label gt " ADD number number"')
call topipe('label gt " Quit"')
/*open the window*/
call topipe("open")
return
rxevent:
/* read the actual comannd string */
parse value readch(ca,in2) with in3 in4 in5 .
/*handle the command*/
if in1=0 then call topipe('result "William H. M. Parker"')
if in1=1 then call topipe('result "'date()'"')
if in1=2 then do
if (datatype(in4,'N') & datatype(in5,'N')) then
call topipe('result "'in4+in5'"')
else call topipe('rc 10')
end
if in1=3 then do
call topipe('result "exiting"')
exit
end
return
topipe:
/* this routine does error checking on lines written to pipe.*/
parse arg out
/* write to the pipe*/
call writeln(ca,out)
/* make sure it worked ok */
if left(readln(ca),2)='ok' then return(0)
/* we exit if something went wrong, we should realy notify the user...*/
exit